package capsolver_go

import (
	"net/url"
	"os"
)

type Endpoint = url.URL

var (
	EndpointA = &Endpoint{Scheme: "https", Host: "api.capsolver.com"}
	EndpointB = &Endpoint{Scheme: "https", Host: "api-stable.capsolver.com"}

	_, _ = EndpointA, EndpointB
)

var ApiHostFromEnvOrDefault *Endpoint

func init() {
	apiHost := os.Getenv("CAPSOLVER_API_HOST")
	u, err := url.Parse(apiHost)
	if apiHost == "" || err != nil {
		ApiHostFromEnvOrDefault = EndpointA
		return
	}
	ApiHostFromEnvOrDefault = u
}
